package com.ece.ecofitness.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ece.ecofitness.jdbcConnection.JdbcConnection;
import com.ece.ecofitness.model.User;
@Service
public class UserDaoImp implements UserDao{

	@Autowired
	private JdbcConnection jdbcConnection;

	public User getUser(String login, String password) {
		User user=null;
		try {
			ResultSet resultat = jdbcConnection.getStat().executeQuery("SELECT * FROM User where login='"+login+"' and password='"+password+"' ;");
			while(resultat.next()){
				user=new User(resultat.getString(1), resultat.getString(2), Boolean.valueOf(resultat.getString(4)),resultat.getString(5),resultat.getString(6));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return user;
	}
	

	
}
